Skip to content

Add support of parsing OPTIMIZE TABLE statement for ClickHouse #1359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2024

Conversation

git-hulk
Copy link
Member

ClickHouse supports using OPTIMIZE TABLE to initialize an unscheduled merge of data parts for tables. The syntax is following:

OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE [BY expression]]

See: https://clickhouse.com/docs/en/sql-reference/statements/optimize

@git-hulk git-hulk force-pushed the feature/optimize-table branch from 452481a to 9ee8988 Compare July 30, 2024 13:27
@coveralls
Copy link

coveralls commented Jul 30, 2024

Pull Request Test Coverage Report for Build 10181475346

Details

  • 80 of 82 (97.56%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 89.213%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ast/mod.rs 15 17 88.24%
Totals Coverage Status
Change from base Build 10169333092: 0.02%
Covered Lines: 27408
Relevant Lines: 30722

💛 - Coveralls

ClickHouse supports using `OPTIMIZE TABLE` to initialize an unscheduled merge
of data parts for tables. The syntax is following:

```SQL
OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION ID 'partition_id'] [FINAL] [DEDUPLICATE [BY expression]]
```

See: https://clickhouse.com/docs/en/sql-reference/statements/optimize
@git-hulk git-hulk force-pushed the feature/optimize-table branch from a95222a to 3c0b347 Compare July 31, 2024 12:06
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub struct Partition {
pub partitions: Vec<Expr>,
pub enum Partition {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the type of Partition from struct to enum to support more parsing states.

@git-hulk
Copy link
Member Author

cc @iffyio

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple minor comments re naming but the changes look good to me overall! Thanks!
cc @alamb

@git-hulk git-hulk force-pushed the feature/optimize-table branch from 7fd63d0 to b4e7026 Compare July 31, 2024 13:46
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @git-hulk and @iffyio -- way to keep the code flowing

@alamb alamb merged commit a692ba5 into apache:main Aug 1, 2024
10 checks passed
lustefaniak pushed a commit to getsynq/sqlparser-rs that referenced this pull request Sep 11, 2024
…e#1359)

# Conflicts:
#	src/ast/ddl.rs
#	src/ast/mod.rs
#	src/parser/mod.rs
#	tests/sqlparser_clickhouse.rs
ayman-sigma pushed a commit to sigmacomputing/sqlparser-rs that referenced this pull request Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants